package com.futu.attraction.controller;

import com.alibaba.fastjson.JSONArray;
import com.futu.attraction.service.AmapSearchService;
import com.futu.common.annotation.NoLoginRequired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/amap02")
public class AmapSearchController {
    @Resource
    private AmapSearchService amapSearchService;

    /**
     * 景点搜索接口
     * @param keyword 景点名称（必填，如"天坛"）
     * @param city    城市（可选，如"北京"）
     * @return 景点信息列表（JSON数组格式）
     */
    @GetMapping("/search-attraction")
    @NoLoginRequired
    public JSONArray searchAttraction(
            @RequestParam String keyword,
            @RequestParam(required = false) String city) throws IOException {
        return amapSearchService.searchAttraction(keyword, city);
    }

    // 保留原有的路线规划接口（若需要）
    // @GetMapping(/route)
    // public JSONObject getRoute(...) { ... }
}